transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

anisotropic scalings.py (544B)


      1 #!/usr/bin/env python2
      2 
      3 from relations.base import *
      4 
      5 class Anisotropic_scalings(Base_relation):
      6     """ Anisotropic scalings class.
      7 
      8     This class has one parameter:
      9     S -- the scaling vector
     10     """
     11     def __init__(self, rng, number, dimension, tag):
     12         """ Initialise the parameter. """
     13         parameters = [ ('S', (dimension,)) ]
     14         super(Anisotropic_scalings, self).__init__(rng, number, parameters, tag)
     15 
     16     def apply(self, inputs, s):
     17         """ Apply the given relations to a given input. """
     18         return s * inputs